/*
 * OledTestCase.cpp
 *
 *  Created on: 2021年9月1日
 *      Author: vicent-PC
 */

#include "OledTestCase.h"

#include "unity.h"
#include "esp_log.h"
#include "screen_driver.h"
#include "ssd1306.h"
#include "ssd1307.h"
#include "ssd1322.h"

#include "Custom_Config.h"

#define FRAME_DURATION (33)

#define MY_TEST_ASSERT(x) if(!(x)) return
#define MY_TEST_ASSERT_RET(x) if(!(x)) return -1

static const char *TAG = "mono lcd test";

static const unsigned char bmp_image_52_24[156] = { /* 0X02,0X01,0X34,0X00,0X18,0X00, */
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1E, 0X82, 0X86, 0X02, 0X1E, 0X06, 0X38, 0X1E, 0X80, 0X06,
    0X1B, 0X1B, 0X00, 0X1A, 0X1C, 0X00, 0X9C, 0X80, 0X80, 0X98, 0X98, 0X80, 0X98, 0X80, 0X83, 0X81,
    0X80, 0X80, 0X00, 0X20, 0X08, 0X00, 0X00, 0X40, 0XC0, 0X04, 0X00, 0X04, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01, 0X80, 0XC0, 0X41, 0X60, 0X60,
    0X20, 0X70, 0X31, 0X18, 0XAC, 0X24, 0X3E, 0X3E, 0X27, 0X31, 0X31, 0X25, 0X35, 0X34, 0X34, 0X20,
    0XF0, 0XBF, 0X3C, 0X39, 0X25, 0X32, 0X39, 0XBD, 0X1A, 0X42, 0X04, 0X2C, 0X38, 0X30, 0X20, 0XC0,
    0X80, 0X02, 0X06, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3C, 0X3F, 0X87,
    0XF8, 0XFC, 0XFE, 0XA6, 0X87, 0XDE, 0XFE, 0XFC, 0XE0, 0XC1, 0XDE, 0XC0, 0XE0, 0XE0, 0XE0, 0XE0,
    0XE0, 0XE0, 0XA0, 0XA0, 0XA0, 0XA0, 0XC0, 0XC0, 0XC0, 0XDE, 0XC9, 0XE2, 0XFF, 0XFF, 0XDE, 0X87,
    0X87, 0XFE, 0XFE, 0XFC, 0XAD, 0XBF, 0X1E, 0X00, 0X00, 0X00, 0X00, 0X00
};

static const unsigned char bmp_image_128_64[1024] = {
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XF8,
    0XFE, 0XFE, 0X3E, 0X78, 0X70, 0X70, 0X78, 0X3E, 0XFE, 0XF8, 0XF8, 0X00, 0XF8, 0XF8, 0X00, 0X00,
    0XF8, 0XF8, 0X00, 0X00, 0X00, 0X00, 0XF8, 0XFE, 0XFE, 0X0E, 0X0E, 0X0E, 0X00, 0X00, 0X00, 0XB0,
    0XB0, 0XF0, 0XF0, 0XC0, 0X00, 0XF0, 0XF0, 0XF0, 0X40, 0X70, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0E, 0X31, 0X46, 0X31, 0X31, 0X0E,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X38, 0X46, 0X46, 0X86, 0X08, 0X86, 0X46, 0X46, 0X38, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F,
    0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X43, 0X5F, 0X5C, 0X5C,
    0X7F, 0X3F, 0X00, 0X00, 0X00, 0X00, 0X03, 0X1F, 0X1F, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X03, 0X1F,
    0X1C, 0X1F, 0X1F, 0X1F, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X1F, 0X1F, 0X00,
    0X00, 0X1F, 0X1F, 0X00, 0X1F, 0X1F, 0X1F, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XC0, 0X20, 0X20, 0X1C, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X80, 0X00, 0X80, 0X00, 0X00, 0X00, 0X03, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XE0,
    0X18, 0X18, 0X18, 0X20, 0X18, 0X18, 0X18, 0XE0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X38, 0XC4, 0XC4, 0X18, 0XC4, 0X38, 0X38, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0XC0, 0XC0, 0XC0, 0XE0, 0X20, 0X20, 0XF8, 0XF8, 0XF8, 0XD8, 0XF8, 0XF8, 0XF8, 0X3C, 0X3C, 0X3C,
    0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XFC, 0X3C, 0X3C, 0X3C, 0XDC, 0XDC, 0XD8, 0XD8, 0XD8,
    0X38, 0X3C, 0X3C, 0X3C, 0XE4, 0XE2, 0XE1, 0XC0, 0XC0, 0XC0, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X02, 0X02, 0X05, 0X1A, 0X05, 0X02, 0X02, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X01, 0X01, 0X02, 0X0C, 0X02, 0X02, 0X01, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X81, 0XE0, 0XF0, 0XF0, 0X70, 0X1C, 0X0C, 0X7E, 0X7E, 0XF3, 0XFF,
    0XFD, 0X1E, 0X1E, 0X0E, 0X01, 0X81, 0X8D, 0X8D, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C, 0X0C,
    0X0C, 0X0C, 0X0C, 0X0C, 0X00, 0X00, 0X80, 0XFF, 0XFE, 0XFE, 0XFE, 0XFC, 0XE0, 0X80, 0X80, 0X10,
    0X11, 0X01, 0X83, 0X83, 0X82, 0X8C, 0X9C, 0XF1, 0XF1, 0XE1, 0X83, 0X0F, 0X0F, 0X0E, 0X1E, 0X7C,
    0X7C, 0X7C, 0XF0, 0XE0, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X0E, 0X11, 0X11,
    0X62, 0X11, 0X0E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X80, 0X80, 0XC0, 0XC0, 0XC0, 0X70, 0X70, 0X78, 0X78, 0X78, 0X78, 0X38, 0X78, 0X78,
    0X4E, 0X4E, 0X4E, 0X0E, 0X0E, 0X8F, 0X87, 0XB9, 0XB9, 0XBE, 0X3E, 0X3E, 0X3E, 0X3E, 0X3F, 0X3F,
    0X3F, 0X3E, 0X3E, 0X0E, 0X0E, 0X0F, 0X0F, 0X0F, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E,
    0X0E, 0X0E, 0X0E, 0X0E, 0X8E, 0X8E, 0XCF, 0X8F, 0X8F, 0X8F, 0X8F, 0X0F, 0X0F, 0X0F, 0X0F, 0X0E,
    0X0E, 0X0E, 0X0F, 0X0F, 0X0F, 0X0F, 0X0F, 0X8F, 0X8F, 0X87, 0X87, 0X46, 0X46, 0X40, 0X00, 0X30,
    0X30, 0X30, 0X31, 0X37, 0X3F, 0X3E, 0X3E, 0X3E, 0X38, 0XF8, 0XC0, 0XC0, 0XC0, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X80, 0XE0, 0XF8,
    0X64, 0X64, 0X67, 0X1F, 0X03, 0X03, 0X00, 0X80, 0XC0, 0XE0, 0XE0, 0XE0, 0XE0, 0XF8, 0XF8, 0XF8,
    0XE0, 0XE0, 0XE0, 0XC0, 0XC0, 0X80, 0X23, 0X43, 0X43, 0X84, 0X1F, 0X78, 0XC0, 0XC0, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0XFF, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0XC0, 0XF8, 0XF8, 0X78, 0X1C, 0XC7, 0X63, 0X63, 0XF8, 0XF8, 0XF8, 0XF8, 0XE0, 0XE0, 0XF8,
    0XF8, 0XF8, 0XF8, 0XF8, 0XF8, 0XE0, 0XE0, 0XE0, 0XC0, 0X80, 0X83, 0X83, 0X07, 0X1F, 0XBC, 0XBC,
    0XF8, 0XE0, 0XC0, 0X80, 0X80, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X3E, 0X3E, 0XFF, 0XFB, 0XFF,
    0X3E, 0X3E, 0X06, 0X02, 0XFC, 0XFC, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFB, 0X03, 0X07, 0X07, 0X07,
    0X03, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0XFC, 0XFC, 0X01, 0X00, 0X00, 0XFF, 0XFF, 0XC0, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0XFF, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0XC7, 0X3F, 0X3F, 0X3C, 0X06, 0X03, 0XFC, 0XFC, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X03,
    0X07, 0X07, 0X07, 0X03, 0X3F, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFE, 0X06, 0XFF, 0XFF,
    0XFF, 0XFF, 0X3F, 0X07, 0X07, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
    0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X01, 0X03, 0X8F,
    0X8E, 0X8E, 0XE0, 0XE0, 0XFF, 0XFF, 0XFF, 0XFF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0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x60,0x00,0xC0,0x40,0x40,0xE0,0xA0,0x90,0xD0,0x50,0xF0,0xF0,0xF0,0xF0,0xB0,0x60,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x19,0x31,0xE0,0x50,0xFF,0xCB,0x8E,0x98,0x18,0x54,0x52,0x51,0x3F,0x10,0x08,0xEF,0xEF,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x1C,0xF4,0x7C,0xDE,0x9E,0xDE,0x7E,0x3C,0x7C,0x78,0xF8,0x38,0x30,0xE0,0xC0,0x70,0x00,0x00,0x00,0xC0,0x20,0x00,0x28,0x67,0xCC,0x90,0x20,0x67,0x69,0x1F,0x9C,0x9E,0x31,0xE3,0xC7,0x6B,0x7F,0x67,0xA3,0xBF,0xFF,0x7C,0x7F,0x3F,0x06,0x84,0xFC,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x1E,0x30,0x41,0xC3,0x86,0x8D,0x8A,0x82,0x84,0x7C,0x48,0x47,0x40,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x3F,0xE0,0x80,0x07,0x1C,0xE0,0x00,0xC0,0x20,0x93,0xCC,0x46,0x21,0x1F,0x00,0x00,0x00,0x00,0x07,0x08,0x08,0x08,0x08,0x10,0xF1,0xA1,0xA2,0x80,0x12,0x12,0x0B,0x03,0x09,0x15,0x05,0xA1,0xA1,0x20,0x22,0x23,0x32,0x1A,0x9D,0x94,0x63,0x0B,0x0F,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0E,0x0C,0x14,0xF7,0x0C,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x02,0xFE,0x0C,0x04,0x02,0x01,0x01,0x02,0x02,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08,0xFF,0x80,0x80,0x80,0xC0,0x40,0x70,0x0C,0x24,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x80,0x80,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x86,0x45,0x24,0x20,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

static const uint8_t chinese[][32] = {
    //王
    {0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x80,0x80,0x81,0x81,0x81,0x81,0x81,0xFF,0x81,0x81,0x81,0x81,0x81,0x80,0x80,0x00},
    //
    {0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x80,0x80,0x81,0x81,0x81,0x81,0x81,0xFF,0x81,0x81,0x89,0xB1,0x81,0x80,0x80,0x00},
    //牛
    {0x00,0x80,0x40,0x3C,0x20,0x20,0x20,0xFE,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00},
    //啊
    {0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x02,0x01,0x00,0x01,0x02,0x04,0x08,0x00,0x00,0x00,0x00}
};

static void contrast_test(esp_err_t (*set_contrast)(uint8_t v))
{
    set_contrast(2);

    uint8_t v = 0, dir = 0, times = 2;
    while (1) {
        if (0 == dir) {
            if (++v >= 25) {
                dir = 1;
                if (0 == times--) {
                    break;
                }
            }
        } else {
            if (--v < 1) {
                dir = 0;
            }
        }
        ESP_LOGI(TAG, "contrast = %d", v * 10);
        set_contrast(v * 10);
        vTaskDelay(FRAME_DURATION / portTICK_PERIOD_MS);
    }
}

void SSD1306_I2C_test()
{
    scr_driver_t lcd;
    scr_info_t lcd_info;
	#if 0
    i2c_config_t i2c_conf = {
        .mode = I2C_MODE_MASTER,
        .sda_io_num = 12,
        .sda_pullup_en = GPIO_PULLUP_ENABLE,
        .scl_io_num = 32,
        .scl_pullup_en = GPIO_PULLUP_ENABLE,
        .master.clk_speed = 100000,
    };
	#endif

	i2c_config_t i2c_conf;
    i2c_conf.mode = I2C_MODE_MASTER;
    i2c_conf.sda_io_num = SDA_PIN;
    i2c_conf.scl_io_num = SCL_PIN;
    i2c_conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
    i2c_conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
    i2c_conf.master.clk_speed = 100*1000;
    i2c_conf.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL;

    i2c_bus_handle_t i2c_bus = i2c_bus_create(I2C_NUM_0, &i2c_conf);
    if(nullptr == i2c_bus) {
		ESP_LOGE(TAG, "nullptr == i2c_bus");
	}

    scr_interface_i2c_config_t iface_cfg = {
        .i2c_bus = i2c_bus,
        .clk_speed = 100000,
        .slave_addr = 0x3C,
    };

    scr_interface_driver_t *iface_drv;
    MY_TEST_ASSERT(ESP_OK == scr_interface_create(SCREEN_IFACE_I2C, &iface_cfg, &iface_drv));
    scr_controller_config_t lcd_cfg = {0};
    lcd_cfg.interface_drv = iface_drv,
    lcd_cfg.pin_num_rst = 0,
    lcd_cfg.pin_num_bckl = -1,
    lcd_cfg.rst_active_level = 0,
    lcd_cfg.bckl_active_level = 1,
    lcd_cfg.width = 128;
    lcd_cfg.height = 64;
    //lcd_cfg.rotate = SCR_DIR_LRTB;
    lcd_cfg.rotate = SCR_DIR_RLBT;
    MY_TEST_ASSERT(ESP_OK == scr_find_driver(SCREEN_CONTROLLER_SSD1306, &lcd));
    MY_TEST_ASSERT(ESP_OK == lcd.init(&lcd_cfg));

    MY_TEST_ASSERT(ESP_OK == lcd.get_info(&lcd_info));
    ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", lcd_info.name, lcd_info.width, lcd_info.height);

    //
    MY_TEST_ASSERT(ESP_OK == lcd.draw_bitmap(0, 0, 128, 64, (uint16_t *)bmp_image_128_64));
    vTaskDelay(FRAME_DURATION / portTICK_PERIOD_MS);

    //
    uint8_t i = 0, j = 0;
    for (i = 0; i < 128 - 52; i++) {
        lcd.draw_bitmap(i, j, 52, 24, (uint16_t *)bmp_image_52_24);
        vTaskDelay(FRAME_DURATION / portTICK_PERIOD_MS);
    }

    contrast_test(lcd_ssd1306_set_contrast);

    lcd.deinit();
    scr_interface_delete(iface_drv);
    i2c_bus_delete(&i2c_bus);
}

OledTestCase::OledTestCase() {
	// TODO Auto-generated constructor stub
    iface_drv = nullptr;
}

OledTestCase::~OledTestCase() {
	// TODO Auto-generated destructor stub
}


void OledTestCase::test() {
	// TODO Auto-generated destructor stub
	SSD1306_I2C_test();
}

void OledTestCase::testWelcome() {
	// TODO Auto-generated destructor stub
	drawBmp(0, 0, 128, 64, (uint16_t *)flower_128x64);
    drawBmp(0, 0, 16, 16, (uint16_t *)chinese[0]);
    drawBmp(0, 16, 16, 16, (uint16_t *)chinese[1]);
    drawBmp(0, 32, 16, 16, (uint16_t *)chinese[2]);
    drawBmp(0, 48, 16, 16, (uint16_t *)chinese[3]);
    vTaskDelay(33 / portTICK_PERIOD_MS);
}

int OledTestCase::init() {
    scr_driver_t lcd;
    scr_info_t lcd_info;

	i2c_config_t i2c_conf;
    i2c_conf.mode = I2C_MODE_MASTER;
    i2c_conf.sda_io_num = SDA_PIN;
    i2c_conf.scl_io_num = SCL_PIN;
    i2c_conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
    i2c_conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
    i2c_conf.master.clk_speed = 100*1000;
    i2c_conf.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL;

    i2c_bus = i2c_bus_create(I2C_NUM_0, &i2c_conf);
    if(nullptr == i2c_bus) {
		ESP_LOGE(TAG, "nullptr == i2c_bus");
	}

    scr_interface_i2c_config_t iface_cfg = {
        .i2c_bus = i2c_bus,
        .clk_speed = 100000,
        .slave_addr = 0x3C,
    };

    MY_TEST_ASSERT_RET(ESP_OK == scr_interface_create(SCREEN_IFACE_I2C, &iface_cfg, &iface_drv));
    scr_controller_config_t lcd_cfg = {0};
    lcd_cfg.interface_drv = iface_drv,
    lcd_cfg.pin_num_rst = 0,
    lcd_cfg.pin_num_bckl = -1,
    lcd_cfg.rst_active_level = 0,
    lcd_cfg.bckl_active_level = 1,
    lcd_cfg.width = 128;
    lcd_cfg.height = 64;
    //lcd_cfg.rotate = SCR_DIR_LRTB;
    lcd_cfg.rotate = SCR_DIR_RLBT;
    MY_TEST_ASSERT_RET(ESP_OK == scr_find_driver(SCREEN_CONTROLLER_SSD1306, &lcd));
    MY_TEST_ASSERT_RET(ESP_OK == lcd.init(&lcd_cfg));

    MY_TEST_ASSERT_RET(ESP_OK == lcd.get_info(&lcd_info));
    ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", lcd_info.name, lcd_info.width, lcd_info.height);
    mLcd = lcd;
    return 0;
}

int OledTestCase::drawBmp(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *bitmap) {
    ESP_LOGI(TAG, "%s E", __func__);
	mLcd.draw_bitmap(x, y, w, h, bitmap);
    ESP_LOGI(TAG, "%s X", __func__);
    return 0;
}

int OledTestCase::deInit() {
    contrast_test(lcd_ssd1306_set_contrast);

    mLcd.deinit();
    scr_interface_delete(iface_drv);
    i2c_bus_delete(&i2c_bus);
    return 0;
}
